import user from "@/store/modules/user";
import { parseTime } from "@/utils/ruoyi";

const filterConditions = {
  // 状态
  state: {
    filterConditions: {
      pageNum: 1,
      pageSize: 30,
      selectedTable: "base",
      timeRange: [
        parseTime(
          new Date(new Date().setHours(0, 0, 0, 0)),
          "{y}-{m}-{d} {h}:{i}:{s}"
        ),
        parseTime(new Date(), "{y}-{m}-{d} {h}:{i}:{s}"),
      ],
      datetime: [
        parseTime(
          new Date(new Date().setHours(0, 0, 0, 0)),
          "{y}-{m}-{d} {h}:{i}:{s}"
        ),
        parseTime(new Date(), "{y}-{m}-{d} {h}:{i}:{s}"),
      ],
      device: "",
      channel: "",
      tableInfo: "db_basedata",
    },
  },

  // mutations用于修改状态
  mutations: {
    // 更新过滤条件
    UPDATE_FILTER_CONDITIONS(state, payload) {
      state.filterConditions = { ...state.filterConditions, ...payload };
    },

    // 重置过滤条件
    RESET_FILTER_CONDITIONS(state) {
      state.filterConditions = {};
    },
  },
};

export default filterConditions;
